package com.marst.first.controller;

import com.marst.first.bean.Menu;
import com.marst.first.bean.VO.Result;
import com.marst.first.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("menu")
public class MenuController {
    @Autowired
    private MenuService menuService;



    @RequestMapping(method = RequestMethod.GET, value = "getMenuList")
    public Result getMenuList(int pageNum, int pageSize, String name, String url) {
        return menuService.getMenuList(pageNum, pageSize, name, url);
    }


    @RequestMapping(method = RequestMethod.GET, value = "getAllMenuList")
    public Result getAllMenuList() {
        return menuService.getAllMenuList();
    }



    @RequestMapping(method = RequestMethod.POST,value = "addMenu")
    public Result addMenu(@RequestBody Menu menu) {
        return menuService.addMenu(menu);
    }



    @RequestMapping(method = RequestMethod.GET,value = "deleteMenu")
    public Result deleteMenu(int id) {
        return menuService.deleteMenu(id);
    }


    @RequestMapping(method = RequestMethod.GET,value = "deleteMenuOnLogic")
    public Result deleteMenuOnLogic(int id) {
        return menuService.deleteMenuOnLogic(id);
    }


    @RequestMapping(method = RequestMethod.GET,value = "getMenuById")
    public Result getMenuById(int id) {
        return menuService.getMenuById(id);
    }


    @RequestMapping(method = RequestMethod.POST,value = "updateMenu")
    public Result updateMenu(@RequestBody Menu menu) {
        return menuService.updateMenu(menu);
    }
}
